

*------------------------------------------------------------------------------*
* Authors: 		Sabine C. Carey (University of Mannheim) and 
*				Juergen Brandsch (KfW Development Bank)
* Article: 		Borders and bullies: How borders shape perceptions of security and foreign policy preferences
* Journal: 		Research & Politics 
* Date: 		2024-01
* Instructions: This do file prepares the data used in the descriptive and analysis do files.
* Stata:		All estimations were done with Stata 18. 			
*------------------------------------------------------------------------------*

clear all
set more off

*-------------------
* Load data
*-------------------
	use "cb_Georgia_data.dta"
	
	
*--------------------------------------------------
* Generate new nominal variables for seccurity risks
*--------------------------------------------------
* Question:
* Let us now talk about what you think about your personal security. 
* Which of the following, if any, do you think currently pose a SEVERE risk to your personal security?

fre b1_*

* Generate a variable for answer "Nothing" to threat to risk to personal security
gen b1_77 = b1_1
recode b1_77 (-9/1 = 0) (77 = 1) (88/99 = .)

* Recode to have only 0 and 1 for the personal risk variables
foreach x of varlist b1_* {
	recode `x' (-9=0) (77/99=0), gen(`x'_new)
}
	drop b1_66_new b1_10_new b1_9_new

	label var b1_1_new "Corruption"
	label var b1_2_new "Non-democratic politicians"
	label var b1_3_new "Violent crime"
	label var b1_4_new "Poverty"
	label var b1_5_new "Tension bw ethnic groups"
	label var b1_6_new "Tension bw religous groups"
	label var b1_7_new "Tension bw political groups"
	label var b1_8_new "Border insecurity"
	label var b1_77_new "Nothing"

rename b1_8_new borderinsec
	label define yesno 0 "No" 1 "Yes", replace
	label value borderinsec yesno
	fre borderinsec
	

*--------------------------------------------------
* Code respondents into AB / SO strata
*--------------------------------------------------

* designating nonresponses as missing (only for distance vars)
foreach x of varlist close_* {
	replace `x' = . if res == 0
}

* South Ossetia: binary var for respondents outside these boundaries
gen not_SO_borderreg = . 
	replace not_SO_borderreg = 0 if close_SO_04 == 1
	replace not_SO_borderreg = 1 if close_SO_04 == 0
	tab not_SO_borderreg close_SO_04
	label var not_SO_borderreg "Outside border region"

	label var close_SO_01 "Within 0.1° SO border"
	label var close_SO_02 "Within 0.2° SO border"
	label var close_SO_03 "Within 0.3° SO border"
	label var close_SO_04 "Within 0.4° SO border"

	
* Abkhazia: binary var for respondents outside these boundaries
gen not_AB_borderreg = . 
	replace not_AB_borderreg = 0 if close_AB_04 == 1
		replace not_AB_borderreg = 1 if close_AB_04 == 0
tab not_AB_borderreg close_AB_04

	label var close_AB_01 "Within 0.1° AB border"
	label var close_AB_02 "Within 0.2° AB border"
	label var close_AB_03 "Within 0.3° AB border"
	label var close_AB_04 "Within 0.4° AB border"
	label var not_AB_borderreg "Outside AB border region"


* Categorical variables for different border regions	

	* 0.1° as border regions 
		gen close_01 = 0
		recode close_01 0=1 if close_SO_01==1
		recode close_01 0=2 if close_AB_01==1
		recode close_01 0=. if close_SO_01==. 
		recode close_01 0=. if close_AB_01==. 
		tab2 close_01 close_SO_01 close_AB_01
		label define close 0 "Outside border region"	///
		1 "Within SO border region" 2 "Within AB border region", replace
		label values close_01 close		
		fre close_01
		
	* 0.2° as border regions 
		gen close_02 = 0
		recode close_02 0=1 if close_SO_02==1
		recode close_02 0=2 if close_AB_02==1
		recode close_02 0=. if close_SO_02==. 
		recode close_02 0=. if close_AB_02==. 
		tab2 close_02 close_SO_02 close_AB_02
		label values close_02 close
		fre close_02		
				
	* 0.3° as border regions 
		gen close_03 =0
		recode close_03 0=1 if close_SO_03==1
		recode close_03 0=2 if close_AB_03==1
		recode close_03 0=. if close_SO_03==. 
		recode close_03 0=. if close_AB_03==. 
		tab2 close_03 close_SO_03 close_AB_03
		label values close_03 close
		fre close_03
	
	* 0.4° as border regions 
		gen close_04 = 0
		recode close_04 0=1 if close_SO_04==1
		recode close_04 0=2 if close_AB_04==1
		recode close_04 0=. if close_SO_04==. 
		recode close_04 0=. if close_AB_04==. 
		tab2 close_04 close_SO_04 close_AB_04
		label values close_04 close
		fre close_04
		
		
*--------------------------------------------------
* Code answers to use of force question
*--------------------------------------------------
* Question: 
* Over the past few years the South Ossetia's administrative borderline has been changed by Russian and South Ossetian armed forces. 
* How strongly do you agree or disagree with the following statement: 
* "If necessary, the Georgian Army should use force to prevent such behaviour in the future"?
	
fre d9
	recode d9 (-9=.) (2=1) (3=2) (4/5=3) (88/99=.), gen(border_force)
	label define categories 	///
		1 "Don't agree" 	///
		2 "Neither" 		///
		3 "Agree", replace
	label values border_force categories
	fre border_force, nomiss

	
*--------------------------------------------------		
* NATO/EU vs Russia as partner by border slices
*--------------------------------------------------
* Question:
* In your opinion, which of the international actors on this CARD should Georgia's armed forces have the closest cooperation with?

fre d7
	recode d7 (-9=.) (1=0) (2=1) (3=0) (4=1) (5/77=0) (88=.) (99=0), gen(NATO_EU)
	recode d7 (-9=.) (1/2=0) (3=1) (4/77=0) (88=.) (99=0), gen(Russia)
	label var NATO_EU "NATO/EU as preferred partner"
	label var Russia "Russia as preferred partner"		
	
* code for use as dependent variable
	recode d7 (-9/1=.) (2=1) (3=2) (4=1) (5=.) (66/88=.) (99=3), gen(d7_cat)
	label define d7_cat 1 "NATO/EU" 2 "Russia" 3 "DK", replace
	label value d7_cat d7_cat 
	fre d7_cat, nomiss	
	rename d7_cat DV_partner	
	
*--------------------------------------------------		
* Prepare control variables for multivariate analyses
*--------------------------------------------------
* Capital
label var tbilisi "Tbilisi"


* dummy for heard about detentions in border regions in last 6 months (D2-C)
* often + all time time, i.e. levels 4+5 on 1-5 scale
* Question:
* Speaking about the last 6 months, how often did you hear about the following incidences in the border regions of Georgia?
* A. Ordinary citizens being detained by Russian or South Ossetian armed forces.
* B. Ordinary citizens being beaten by Russian or South Ossetian armed forces.
* C. Ordinary citizens being abducted by Russian or South Ossetian armed forces.
* D. Ordinary citizens being killed by Russian or South Ossetian armed forces.

fre d2_a 
	recode d2_a (-9/-3=.) (1/3=0) (4/5=1) (88/99=.), gen (heard_detained)
	label var heard_detained "Heard about detentions"
	tab d2_a heard_detained

fre d2_b 
	recode d2_b (-9=.) (1/3=0) (4/5=1) (88/99=.), gen (heard_beaten)
	label var heard_beaten "Heard about beatings"
	tab d2_b heard_beaten

fre d2_c 
	recode d2_c (-9=.) (1/3=0) (4/5=1) (88/99=.), gen (heard_abducted)
	label var heard_abducted "Heard about abductions"
	tab d2_c heard_abducted

fre d2_d
	recode d2_d (-9=.) (1/3=0) (4/5=1) (88/99=.), gen (heard_killed)
	label var heard_killed "Heard about killings"
	tab d2_d heard_killed

	gen heard_violence =.
	recode heard_violence .=0 if heard_detained==0 & heard_beaten==0 & heard_abducted==0 & heard_killed==0
	recode heard_violence .=1 if heard_detained==1 | heard_beaten==1 |  heard_abducted==1 | heard_killed==1
	label var heard_violence "Heard about border violence"
	label value heard_violence yesno
	fre heard_violence
	tab heard_violence heard_abducted
	tab heard_violence heard_beaten	

* Harmed in either 1993/93 or 2008 war
* Questions:
* Have you or someone you personally know been physically harmed during the armed conflicts in 1992-1993?
* Have you or someone you personally know been physically harmed during the 2008 August war?
	recode f6 (2=0) (3=1) (-9/-3=.) (88/99=.), gen(harmed)
	recode harmed (0=1) (.=1) if f5==3
	label var harmed "Harmed in war"
	
	
* Economic condition, subjective assessment, scale 1-5
* Question:
* Would you assess your current economic condition as very bad, fairly bad, average, fairly good, or very good?
fre a6
	recode a6 (-9/-3=.) (88/99=.), gen(econ_cond)
	label var econ_cond "Own economic condition"
	label define econ 1 "Very bad" 2 "Fairly bad" 3 "Average" 4 "Fairly good" 5 "Very good"
	label val econ_cond econ
	fre econ_cond	
	
	
* University degree, completed BA degree or higher
fre h6 
	recode h6 (-9/-3=.) (1/4=0) (5/7=1) (88/99=.), gen(uni_degree)
	label var uni_degree "University degree"
	tab h6 uni_degree

	
* Sex
fre sex
	recode sex (-7=.) (1=0) (2=1), gen(female)
	tab sex female
	label var female "Female"	
	
	
* Age categories
	recode age (-7=.) (18/40=1) (41/60=2) (61/98=3), gen(agecat)
	label define age_spine 1 "Age 18-40" 2 "Age 41-60" 3 "Age 61-98", replace
	label value agecat age_spine		
	
	
* European values
* Question:
* Which of the following statements is closest to your view?
* Statement 1: European political values are not compatible with Georgian political values.
* Statement 2: Georgia will benefit from sharing the European political values.
	recode g3 (-9=.) (1=2) (3/4=3) (5=1) (88=.) (99=1), gen(europ_values)
	label define categories_3values 	///
		1 "Don't know"		///
		2 "Europ. values not compatible" 	///
		3 "Europ. values benefit" 		, replace
	label values europ_values categories_3values
	fre europ_values, nomiss
	
	save "cb_Georgia_data_prep.dta", replace
	
* END data preparation		
